<?php

namespace app\admin\validate;

use think\Validate;

class activitycate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
    public function __construct()
    {
        parent::__construct();
        if(request()->isPost())
        {
            $this->rule['name'] = 'require|max:10|unique:activity_categories';
        }
        elseif (request()->isPut()) 
        {
            $this->rule['name'] = 'require|max:10';
        }
    }

	protected $rule = [
        //'name' => 'require|max:10|unique:activity_categories',
        'sorder' => 'integer',
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'name.require' => '分类名称不许为空',
        'name.max' => '分类名称不能超过10个字',
        'name.unique' => '分类名称已存在',
        'sorder.integer' => '排序必须是数字', 
    ];
}
